package com.lance.answer.gui.answer.gk.video.tmp.tmp;

import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.lance.answer.gui.answer.AnswerObject;
import com.lance.answer.gui.answer.Util;
import com.lance.answer.gui.answer.gk.DealInfoUtil;
import com.lance.answer.gui.answer.gk.answer.AnswerDTO;
import com.lance.answer.gui.answer.gk.answer.task.UploadFileTask;
import com.lance.answer.gui.answer.gk.video.dto.WatchVideoDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.LinkedBlockingDeque;

@Slf4j
public class UploadFiletmppppppppp {

    /**
     * 进度表：
     * 6-18 19:55开始测试 公共行政学 行政管理专科
     *
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        int sync = 12;

       // Thread.sleep(1000*60*60*9);
        Map<String,List<String>> all = Maps.newHashMap();

        all.put("思想道德修养与法律基础",Lists.newArrayList("http://xinjiang.ouchn.cn/mod/assign/view.php?id=242355",
                "http://xinjiang.ouchn.cn/mod/assign/view.php?id=242482"));
        all.put("习近平新时代中国特色社会主义思想",Lists.newArrayList("http://xinjiang.ouchn.cn/mod/assign/view.php?id=243283"));
        all.put("毛泽东思想和中国特色社会主义理论体系概论",Lists.newArrayList("http://xinjiang.ouchn.cn/mod/assign/view.php?id=242717","http://xinjiang.ouchn.cn/mod/assign/view.php?id=242842"));
     //   all.put("马克思主义基本原理概论",Lists.newArrayList("http://xinjiang.ouchn.cn/mod/assign/view.php?id=242595"));
     //   all.put("思想道德与法治",Lists.newArrayList("http://xinjiang.ouchn.cn/mod/assign/view.php?id=318697"));
       //  有两套！！！！！
       // all.put("中国近现代史纲要",Lists.newArrayList("http://xinjiang.ouchn.cn/mod/assign/view.php?id=242980","http://xinjiang.ouchn.cn/mod/assign/view.php?id=243113"));
        all.put("计算机应用基础",Lists.newArrayList("http://xinjiang.ouchn.cn/mod/assign/view.php?id=244497"));



    //    List<String> subjectList = Lists.newArrayList();
        /**
         * http://xinjiang.ouchn.cn/mod/assign/view.php?id=242355 人数多
         * http://xinjiang.ouchn.cn/mod/assign/view.php?id=242482
         * 大作业yo两种链接
         */
      //  subjectList.add("思想道德修养与法律基础");

        LinkedBlockingDeque<AnswerDTO> answerQueue = new LinkedBlockingDeque<>();


        for(String subjectName:all.keySet()){
            //  LinkedList<AnswerRequestDTO> requestUrl = Lists.newLinkedList();
            LinkedList<String> requestUrl = Lists.newLinkedList(all.get(subjectName));

            log.info("subjectName:{}",subjectName);

       //     InputStream inputStream2 = new FileInputStream("d:\\0103.user");
            InputStream inputStream2 = new FileInputStream("d:\\0104"+subjectName+".user");
            List<String> users = IOUtils.readLines(inputStream2, "utf-8");
            for(String user:users){
                String[] strs = user.split(",");
                String userCode = strs[0];
                String pwd = strs[1].substring(6, 14);
                pwd = "Ouchn" + pwd;
                AnswerDTO answerDTO = new AnswerDTO();
                answerDTO.setSubjectName(subjectName);
                answerDTO.setUsername(userCode);
                answerDTO.setPwd(pwd);
                answerDTO.setCommit(true);
                answerDTO.setPush(false);
                answerDTO.setUploadUrl(requestUrl);
                answerQueue.add(answerDTO);
            }


        }

        for (int i = 1; i <= sync; i++) {
            Thread answerThread = new UploadFileTasktmpppppppppppp(null,answerQueue);
            //log.info("加载课程ID：{} 名称：{} ", openCourseId,subjectName);
            answerThread.setName( "答题线程--" + i);
            answerThread.start();
        }


    }






}
